import { createRouter, createWebHashHistory } from 'vue-router'
import layout from '@/layout'

/**
 * 私有路由表
 */
const privateRoutes = [
  {
    path: '/',
    component: layout,
    redirect: '/basic/border',
    meta: {
      title: 'basic',
      icon: 'chart'
    },
    children: [
      {
        path: '/basic/border',
        component: () => import('@/views/basic/border'),
        meta: {
          title: 'border',
          icon: 'chart'
        }
      },
      {
        path: '/basic/button',
        component: () => import('@/views/basic/button'),
        meta: {
          title: 'button',
          icon: 'chart'
        }
      },
      {
        path: '/basic/color',
        component: () => import('@/views/basic/color'),
        meta: {
          title: 'color',
          icon: 'chart'
        }
      }
    ]
  },
  {
    path: '/form',
    component: layout,
    redirect: '/form/form',
    meta: {
      title: 'form',
      icon: 'chart'
    },
    children: [
      {
        path: '/form/form',
        component: () => import('@/views/form/form'),
        meta: {
          title: 'form',
          icon: 'chart'
        }
      },
      {
        path: '/form/input',
        component: () => import('@/views/form/input'),
        meta: {
          title: 'input',
          icon: 'chart'
        }
      }
    ]
  },
  {
    path: '/table',
    component: layout,
    redirect: '/table/table',
    meta: {
      title: 'table',
      icon: 'chart'
    },
    children: [
      {
        path: '/table/table',
        component: () => import('@/views/table/table'),
        meta: {
          title: 'table',
          icon: 'chart'
        }
      },
      {
        path: '/table/table2',
        component: () => import('@/views/table/table2'),
        meta: {
          title: 'table2',
          icon: 'chart'
        }
      }
    ]
  }
]
/**
 * 公开路由表
 */
const publicRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: [...publicRoutes, ...privateRoutes]
})

export default router
